<template>
    <view>
        <uni-list :border="false">
            <uni-list-item v-for="(item,index) in cardDatas" :key="index" :title="item.title" :note="note(item)"
                :clickable="true" @click="getDetail(item)">
                <template v-slot:footer>
                    <view v-if="item.image" class="uni-thumb" style="margin: 0;">
                        <image :src="item.image+'?x-oss-process=image/resize,w_400,m_lfit'" mode="aspectFill"></image>
                    </view>
                </template>
            </uni-list-item>
        </uni-list>
    </view>
</template>

<script>
    /**
     * 栏目 - 横向 - 右图
     * @description 此组件一般用于展示数据列表。
     * @tutorial https://www.dfer.site
     * @property {Number} type 数据类型
     * @property {Array} cardDatas 数据列表
     * @example <dfer-horizontally-right-img-list :cardDatas="item.data.value" :type="item.id" />
     */
    export default {
        name: "dfer-horizontally-right-img-list",
        data() {
            return {};
        },
        props: {
            cardDatas: {
                required: true,
            },
            type: {
                default: 0,
                type: Number
            }
        },
        methods: {
            getDetail(item) {
                console.log(this.$options.name, this.type, item);
                switch (this.type) {
                    case this.ktpType.wd.id:
                        uni.navigateTo({
                            url: '/pages/index/detail_wd?id=' + item.id
                        })
                        break;
                    default:
                        if (item.content)
                            uni.navigateTo({
                                url: `/pages/index/detail?type=${this.type}&data=${encodeURIComponent(JSON.stringify(item))}`
                            })
                        break;
                }
            },
            note(item) {
                let list = [];
                if (item.user_name) {
                    list.push(`发布人:${item.user_name}`);
                }
                list.push(`时间:${item.time}`);
                return list.join(' ');
            }

        }

    }
</script>

<style>

</style>